package com.ruoyi.ncpsy.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.ncpsy.domain.NcpsyOtherEvent;
import com.ruoyi.ncpsy.service.INcpsyOtherEventService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 其他事件记录Controller
 * 
 * @author ruoyi
 * @date 2025-09-01
 */
@RestController
@RequestMapping("/ncpsy/otherEvent")
public class NcpsyOtherEventController extends BaseController
{
    @Autowired
    private INcpsyOtherEventService ncpsyOtherEventService;

    /**
     * 查询其他事件记录列表
     */
    @PreAuthorize("@ss.hasPermi('ncpsy:otherEvent:list')")
    @GetMapping("/list")
    public TableDataInfo list(NcpsyOtherEvent ncpsyOtherEvent)
    {
        startPage();
        List<NcpsyOtherEvent> list = ncpsyOtherEventService.selectNcpsyOtherEventList(ncpsyOtherEvent);
        return getDataTable(list);
    }

    /**
     * 导出其他事件记录列表
     */
    @PreAuthorize("@ss.hasPermi('ncpsy:otherEvent:export')")
    @Log(title = "其他事件记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, NcpsyOtherEvent ncpsyOtherEvent)
    {
        List<NcpsyOtherEvent> list = ncpsyOtherEventService.selectNcpsyOtherEventList(ncpsyOtherEvent);
        ExcelUtil<NcpsyOtherEvent> util = new ExcelUtil<NcpsyOtherEvent>(NcpsyOtherEvent.class);
        util.exportExcel(response, list, "其他事件记录数据");
    }

    /**
     * 获取其他事件记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('ncpsy:otherEvent:query')")
    @GetMapping(value = "/{otherEventId}")
    public AjaxResult getInfo(@PathVariable("otherEventId") Long otherEventId)
    {
        return success(ncpsyOtherEventService.selectNcpsyOtherEventByOtherEventId(otherEventId));
    }

    /**
     * 新增其他事件记录
     */
    @PreAuthorize("@ss.hasPermi('ncpsy:otherEvent:add')")
    @Log(title = "其他事件记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody NcpsyOtherEvent ncpsyOtherEvent) throws Exception {
        return toAjax(ncpsyOtherEventService.insertNcpsyOtherEvent(ncpsyOtherEvent));
    }

    /**
     * 修改其他事件记录
     */
    @PreAuthorize("@ss.hasPermi('ncpsy:otherEvent:edit')")
    @Log(title = "其他事件记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody NcpsyOtherEvent ncpsyOtherEvent)
    {
        return toAjax(ncpsyOtherEventService.updateNcpsyOtherEvent(ncpsyOtherEvent));
    }

    /**
     * 删除其他事件记录
     */
    @PreAuthorize("@ss.hasPermi('ncpsy:otherEvent:remove')")
    @Log(title = "其他事件记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{otherEventIds}")
    public AjaxResult remove(@PathVariable Long[] otherEventIds)
    {
        return toAjax(ncpsyOtherEventService.deleteNcpsyOtherEventByOtherEventIds(otherEventIds));
    }
}
